﻿using UnityEngine;
using System.Collections;
using UI;
using Base.Extensions;
public class 报修清单 : BasePanel
{
    public UnityEngine.Object Object;
    private Transform form;
    // Use this for initialization
    private void Awake()
    {
        form = transform.Find("Scroll View/Viewport/Content");

    }
    void Start()
    {

    }
    private string GetGuid()
    {
        System.Guid guid = new System.Guid();
        guid = System.Guid.NewGuid();
        return guid.ToString();
    }

    public override void OnEnter()
    {
        gameObject.SetActive(true);
    }
    public override void OnExit()
    {
        gameObject.SetActive(false);
    }
    public void 新建表单(Transform form)
    {
        form.Find("Titles/InputField").SetInputText(GetGuid().Replace('-', ' '));
        form.Find("Titles/InputField1").SetInputText(System.DateTime.Now.ToString());
        form.Find("Titles/InputField2").SetInputText("输入故障描述");
        //form.Find("Titles/Dropdown/Label").SetText("保养人");
        form.Find("Titles/Text").SetText("派单");
        form.Find("Titles/Text1").SetText("未维修");
        form.Find("Titles/Text2").SetText("未审核");
    }
    public void 提交新建表单(Transform transform)
    {
        Debug.LogError("注册新建表单事件完成添加记录");
        注册维护表单(transform);
    }
    void 注册维护表单(Transform _transform)
    {
        GameObject _gameObject = Instantiate(Object) as GameObject;
        _gameObject.SetActive(true);
        _gameObject.transform.parent = form;
        _gameObject.transform.localPosition = Vector3.zero;
        _gameObject.transform.localScale = Vector3.one;

        string 报修单号 = _transform.Find("Titles/InputField/Text").GetText();
        string 报修时间 = _transform.Find("Titles/InputField1/Text").GetText();
        string 故障描述 = _transform.Find("Titles/InputField2/Text").GetText();
        string 报修人员 = _transform.Find("Titles/Dropdown/Label").GetText();
        string 紧急程度 = _transform.Find("Titles/Dropdown1/Label").GetText();
        string 派单状态 = _transform.Find("Titles/Text").GetText();
        string 维修状态 = _transform.Find("Titles/Text1").GetText(); 
        string 审核状态 = _transform.Find("Titles/Text2").GetText();




        _gameObject.transform.Find("Titles/Text").SetText(报修单号);
        _gameObject.transform.Find("Titles/Text (1)").SetText(报修时间);
        _gameObject.transform.Find("Titles/Text (2)").SetText(故障描述);
        _gameObject.transform.Find("Titles/Text (3)").SetText(紧急程度);
        _gameObject.transform.Find("Titles/Text (4)").SetText(System.DateTime.Now.ToString());
        _gameObject.transform.Find("Titles/Text (5)").SetText("张三");
        //_gameObject.transform.Find("Titles/Dropdown/Label").SetText("张三");
        _gameObject.transform.Find("Titles/Text (7)").SetText(System.DateTime.Now.ToString());
        _gameObject.transform.Find("Titles/Text (8)").SetText("张三");
        _gameObject.transform.Find("Titles/Text (9)").SetText(派单状态);
    }
    // Update is called once per frame
    void Update()
    {

    }
    public void 关闭界面()
    {
        UIManager.Instance.PopPanel();
    }
}
